<!-- HTML header for doxygen 1.9.1-->
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=9" />
    <meta name="generator" content="Doxygen 1.9.4" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>NumCpp: gauss_legendre.hpp Source File</title>
    <link href="tabs.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript" src="dynsections.js"></script>
    <link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
    <link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
    <link href="doxygen.css" rel="stylesheet" type="text/css" />
    <link href="doxygen-awesome.css" rel="stylesheet" type="text/css"/>
<link href="doxygen-awesome-sidebar-only-darkmode-toggle.css" rel="stylesheet" type="text/css"/>
    <!-- ... other metadata & script includes ... -->
    <script type="text/javascript" src="../doxygen-awesome-css/doxygen-awesome-darkmode-toggle.js"></script>
    <script type="text/javascript">
        DoxygenAwesomeDarkModeToggle.init()
    </script>
    <script type="text/javascript"
        src="../doxygen-awesome-css/doxygen-awesome-fragment-copy-button.js"></script>
    <script type="text/javascript">
        DoxygenAwesomeFragmentCopyButton.init()
    </script>
    <script type="text/javascript" src="../doxygen-awesome-css/doxygen-awesome-paragraph-link.js"></script>
    <script type="text/javascript">
        DoxygenAwesomeParagraphLink.init()
    </script>
    <script type="text/javascript" src="../doxygen-awesome-css/doxygen-awesome-interactive-toc.js"></script>
    <script type="text/javascript">
        DoxygenAwesomeInteractiveToc.init()
    </script>
</head>
<body>
    <div id="top">
        <!-- do not remove this div, it is closed by doxygen! -->
        <div id="titlearea">
            <table cellspacing="0" cellpadding="0">
                <tbody>
                    <tr style="height: 56px;">
                        <td id="projectlogo"><img alt="Logo" src="NumCppLogoDoxygen.png" /></td>
                        <td id="projectalign" style="padding-left: 0.5em;">
                            <div id="projectname">NumCpp
                                &#160;<span id="projectnumber">2.12.1</span>
                            </div>
                            <div id="projectbrief">A Templatized Header Only C++ Implementation of the Python NumPy Library</div>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
        <!-- end header part --><!-- Generated by Doxygen 1.9.4 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('gauss__legendre_8hpp_source.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle"><div class="title">gauss_legendre.hpp</div></div>
</div><!--header-->
<div class="contents">
<a href="gauss__legendre_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno">    1</span> </div>
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno">   32</span><span class="preprocessor">#pragma once</span></div>
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno">   33</span> </div>
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno">   34</span><span class="preprocessor">#include &lt;cmath&gt;</span></div>
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno">   35</span><span class="preprocessor">#include &lt;functional&gt;</span></div>
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno">   36</span><span class="preprocessor">#include &lt;vector&gt;</span></div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno">   37</span> </div>
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno">   38</span><span class="preprocessor">#include &quot;<a class="code" href="_core_2_constants_8hpp.html">NumCpp/Core/Constants.hpp</a>&quot;</span></div>
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno">   39</span><span class="preprocessor">#include &quot;<a class="code" href="_types_8hpp.html">NumCpp/Core/Types.hpp</a>&quot;</span></div>
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno">   40</span><span class="preprocessor">#include &quot;<a class="code" href="sqr_8hpp.html">NumCpp/Utils/sqr.hpp</a>&quot;</span></div>
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno">   41</span> </div>
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno"><a class="line" href="namespacenc_1_1integrate.html">   42</a></span><span class="keyword">namespace </span><a class="code hl_namespace" href="namespacenc_1_1integrate.html">nc::integrate</a></div>
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno">   43</span>{</div>
<div class="line"><a id="l00044" name="l00044"></a><span class="lineno">   44</span>    <span class="comment">//============================================================================</span></div>
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno">   45</span>    <span class="comment">// Class Description:</span></div>
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno"><a class="line" href="classnc_1_1integrate_1_1_legendre_polynomial.html">   48</a></span><span class="comment"></span>    <span class="keyword">class </span><a class="code hl_class" href="classnc_1_1integrate_1_1_legendre_polynomial.html">LegendrePolynomial</a></div>
<div class="line"><a id="l00049" name="l00049"></a><span class="lineno">   49</span>    {</div>
<div class="line"><a id="l00050" name="l00050"></a><span class="lineno">   50</span>    <span class="keyword">public</span>:</div>
<div class="line"><a id="l00051" name="l00051"></a><span class="lineno">   51</span>        <span class="comment">//============================================================================</span></div>
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno">   52</span>        <span class="comment">// Method Description:</span></div>
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno"><a class="line" href="classnc_1_1integrate_1_1_legendre_polynomial.html#a2e1fefae138e66215cd7586a85fc3642">   57</a></span><span class="comment"></span>        <span class="keyword">explicit</span> <a class="code hl_function" href="classnc_1_1integrate_1_1_legendre_polynomial.html#a2e1fefae138e66215cd7586a85fc3642">LegendrePolynomial</a>(<span class="keyword">const</span> <a class="code hl_typedef" href="namespacenc.html#af0f49663fb63332596e2e6327009d581">uint32</a> numIterations) noexcept :</div>
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno">   58</span>            numIterations_(numIterations),</div>
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno">   59</span>            weight_(numIterations + 1),</div>
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno">   60</span>            root_(numIterations + 1)</div>
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno">   61</span>        {</div>
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno">   62</span>            calculateWeightAndRoot();</div>
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno">   63</span>        }</div>
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno">   64</span> </div>
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno">   65</span>        <span class="comment">//============================================================================</span></div>
<div class="line"><a id="l00066" name="l00066"></a><span class="lineno">   66</span>        <span class="comment">// Method Description:</span></div>
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno"><a class="line" href="classnc_1_1integrate_1_1_legendre_polynomial.html#a5a97c4c53f878cda71129dbd4398b1a9">   71</a></span><span class="comment"></span>        [[nodiscard]] <span class="keyword">const</span> std::vector&lt;double&gt;&amp; <a class="code hl_function" href="classnc_1_1integrate_1_1_legendre_polynomial.html#a5a97c4c53f878cda71129dbd4398b1a9">getWeight</a>() const noexcept</div>
<div class="line"><a id="l00072" name="l00072"></a><span class="lineno">   72</span>        {</div>
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno">   73</span>            <span class="keywordflow">return</span> weight_;</div>
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno">   74</span>        }</div>
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno">   75</span> </div>
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno">   76</span>        <span class="comment">//============================================================================</span></div>
<div class="line"><a id="l00077" name="l00077"></a><span class="lineno">   77</span>        <span class="comment">// Method Description:</span></div>
<div class="line"><a id="l00082" name="l00082"></a><span class="lineno"><a class="line" href="classnc_1_1integrate_1_1_legendre_polynomial.html#a50df5ad7c7312b1bf814fcf8b5bb0d94">   82</a></span><span class="comment"></span>        [[nodiscard]] <span class="keyword">const</span> std::vector&lt;double&gt;&amp; <a class="code hl_function" href="classnc_1_1integrate_1_1_legendre_polynomial.html#a50df5ad7c7312b1bf814fcf8b5bb0d94">getRoot</a>() const noexcept</div>
<div class="line"><a id="l00083" name="l00083"></a><span class="lineno">   83</span>        {</div>
<div class="line"><a id="l00084" name="l00084"></a><span class="lineno">   84</span>            <span class="keywordflow">return</span> root_;</div>
<div class="line"><a id="l00085" name="l00085"></a><span class="lineno">   85</span>        }</div>
<div class="line"><a id="l00086" name="l00086"></a><span class="lineno">   86</span> </div>
<div class="line"><a id="l00087" name="l00087"></a><span class="lineno">   87</span>    <span class="keyword">private</span>:</div>
<div class="line"><a id="l00088" name="l00088"></a><span class="lineno">   88</span>        <span class="comment">//============================================================================</span></div>
<div class="line"><a id="l00089" name="l00089"></a><span class="lineno">   89</span>        <span class="comment">// Class Description:</span></div>
<div class="line"><a id="l00092" name="l00092"></a><span class="lineno">   92</span><span class="comment"></span>        <span class="keyword">struct </span>Result</div>
<div class="line"><a id="l00093" name="l00093"></a><span class="lineno">   93</span>        {</div>
<div class="line"><a id="l00094" name="l00094"></a><span class="lineno">   94</span>            <span class="keywordtype">double</span> value{ 0. };</div>
<div class="line"><a id="l00095" name="l00095"></a><span class="lineno">   95</span>            <span class="keywordtype">double</span> derivative{ 0. };</div>
<div class="line"><a id="l00096" name="l00096"></a><span class="lineno">   96</span> </div>
<div class="line"><a id="l00097" name="l00097"></a><span class="lineno">   97</span>            <span class="comment">//============================================================================</span></div>
<div class="line"><a id="l00098" name="l00098"></a><span class="lineno">   98</span>            <span class="comment">// Method Description:</span></div>
<div class="line"><a id="l00104" name="l00104"></a><span class="lineno">  104</span><span class="comment"></span>            Result(<span class="keyword">const</span> <span class="keywordtype">double</span> val, <span class="keyword">const</span> <span class="keywordtype">double</span> deriv) noexcept :</div>
<div class="line"><a id="l00105" name="l00105"></a><span class="lineno">  105</span>                value(val),</div>
<div class="line"><a id="l00106" name="l00106"></a><span class="lineno">  106</span>                derivative(deriv)</div>
<div class="line"><a id="l00107" name="l00107"></a><span class="lineno">  107</span>            {</div>
<div class="line"><a id="l00108" name="l00108"></a><span class="lineno">  108</span>            }</div>
<div class="line"><a id="l00109" name="l00109"></a><span class="lineno">  109</span>        };</div>
<div class="line"><a id="l00110" name="l00110"></a><span class="lineno">  110</span> </div>
<div class="line"><a id="l00111" name="l00111"></a><span class="lineno">  111</span>        <span class="comment">//============================================================================</span></div>
<div class="line"><a id="l00112" name="l00112"></a><span class="lineno">  112</span>        <span class="comment">// Method Description:</span></div>
<div class="line"><a id="l00115" name="l00115"></a><span class="lineno">  115</span><span class="comment"></span>        <span class="keywordtype">void</span> calculateWeightAndRoot() noexcept</div>
<div class="line"><a id="l00116" name="l00116"></a><span class="lineno">  116</span>        {</div>
<div class="line"><a id="l00117" name="l00117"></a><span class="lineno">  117</span>            <span class="keyword">const</span> <span class="keyword">auto</span> numIterationsDouble = <span class="keyword">static_cast&lt;</span><span class="keywordtype">double</span><span class="keyword">&gt;</span>(numIterations_);</div>
<div class="line"><a id="l00118" name="l00118"></a><span class="lineno">  118</span>            <span class="keywordflow">for</span> (<a class="code hl_typedef" href="namespacenc.html#af0f49663fb63332596e2e6327009d581">uint32</a> step = 0; step &lt;= numIterations_; ++step)</div>
<div class="line"><a id="l00119" name="l00119"></a><span class="lineno">  119</span>            {</div>
<div class="line"><a id="l00120" name="l00120"></a><span class="lineno">  120</span>                <span class="keywordtype">double</span> root =</div>
<div class="line"><a id="l00121" name="l00121"></a><span class="lineno">  121</span>                    <a class="code hl_function" href="namespacenc.html#a736de91eb8f79bfaf4dc92d7161f1c87">std::cos</a>(<a class="code hl_variable" href="namespacenc_1_1constants.html#a2f1219a120c9cc1434486d9de75a8221">constants::pi</a> * (<span class="keyword">static_cast&lt;</span><span class="keywordtype">double</span><span class="keyword">&gt;</span>(step) - 0.25) / (numIterationsDouble + 0.5));</div>
<div class="line"><a id="l00122" name="l00122"></a><span class="lineno">  122</span>                Result result = calculatePolynomialValueAndDerivative(root);</div>
<div class="line"><a id="l00123" name="l00123"></a><span class="lineno">  123</span> </div>
<div class="line"><a id="l00124" name="l00124"></a><span class="lineno">  124</span>                <span class="keywordtype">double</span> newtonRaphsonRatio;</div>
<div class="line"><a id="l00125" name="l00125"></a><span class="lineno">  125</span>                <span class="keywordflow">do</span></div>
<div class="line"><a id="l00126" name="l00126"></a><span class="lineno">  126</span>                {</div>
<div class="line"><a id="l00127" name="l00127"></a><span class="lineno">  127</span>                    newtonRaphsonRatio = result.value / result.derivative;</div>
<div class="line"><a id="l00128" name="l00128"></a><span class="lineno">  128</span>                    root -= newtonRaphsonRatio;</div>
<div class="line"><a id="l00129" name="l00129"></a><span class="lineno">  129</span>                    result = calculatePolynomialValueAndDerivative(root);</div>
<div class="line"><a id="l00130" name="l00130"></a><span class="lineno">  130</span>                } <span class="keywordflow">while</span> (std::fabs(newtonRaphsonRatio) &gt; EPSILON);</div>
<div class="line"><a id="l00131" name="l00131"></a><span class="lineno">  131</span> </div>
<div class="line"><a id="l00132" name="l00132"></a><span class="lineno">  132</span>                root_[step]   = root;</div>
<div class="line"><a id="l00133" name="l00133"></a><span class="lineno">  133</span>                weight_[step] = 2. / ((1. - <a class="code hl_function" href="namespacenc_1_1utils.html#ae792e10a24b7e5b8291a6c31a28a4512">utils::sqr</a>(root)) * result.derivative * result.derivative);</div>
<div class="line"><a id="l00134" name="l00134"></a><span class="lineno">  134</span>            }</div>
<div class="line"><a id="l00135" name="l00135"></a><span class="lineno">  135</span>        }</div>
<div class="line"><a id="l00136" name="l00136"></a><span class="lineno">  136</span> </div>
<div class="line"><a id="l00137" name="l00137"></a><span class="lineno">  137</span>        <span class="comment">//============================================================================</span></div>
<div class="line"><a id="l00138" name="l00138"></a><span class="lineno">  138</span>        <span class="comment">// Method Description:</span></div>
<div class="line"><a id="l00144" name="l00144"></a><span class="lineno">  144</span><span class="comment"></span>        Result calculatePolynomialValueAndDerivative(<span class="keyword">const</span> <span class="keywordtype">double</span> x) <span class="keyword">noexcept</span></div>
<div class="line"><a id="l00145" name="l00145"></a><span class="lineno">  145</span>        {</div>
<div class="line"><a id="l00146" name="l00146"></a><span class="lineno">  146</span>            Result result(x, 0.);</div>
<div class="line"><a id="l00147" name="l00147"></a><span class="lineno">  147</span> </div>
<div class="line"><a id="l00148" name="l00148"></a><span class="lineno">  148</span>            <span class="keywordtype">double</span>       value_minus_1 = 1.;</div>
<div class="line"><a id="l00149" name="l00149"></a><span class="lineno">  149</span>            <span class="keyword">const</span> <span class="keywordtype">double</span> <a class="code hl_function" href="namespacenc_1_1random_1_1detail.html#af5bfd54c6d5d0ad7e16e6e532b0dfb2e">f</a>             = 1. / (<a class="code hl_function" href="namespacenc_1_1utils.html#ae792e10a24b7e5b8291a6c31a28a4512">utils::sqr</a>(x) - 1.);</div>
<div class="line"><a id="l00150" name="l00150"></a><span class="lineno">  150</span>            <span class="keywordflow">for</span> (<a class="code hl_typedef" href="namespacenc.html#af0f49663fb63332596e2e6327009d581">uint32</a> step = 2; step &lt;= numIterations_; ++step)</div>
<div class="line"><a id="l00151" name="l00151"></a><span class="lineno">  151</span>            {</div>
<div class="line"><a id="l00152" name="l00152"></a><span class="lineno">  152</span>                <span class="keyword">const</span> <span class="keyword">auto</span>   stepDouble = <span class="keyword">static_cast&lt;</span><span class="keywordtype">double</span><span class="keyword">&gt;</span>(step);</div>
<div class="line"><a id="l00153" name="l00153"></a><span class="lineno">  153</span>                <span class="keyword">const</span> <span class="keywordtype">double</span> value =</div>
<div class="line"><a id="l00154" name="l00154"></a><span class="lineno">  154</span>                    ((2. * stepDouble - 1.) * x * result.value - (stepDouble - 1.) * value_minus_1) / stepDouble;</div>
<div class="line"><a id="l00155" name="l00155"></a><span class="lineno">  155</span>                result.derivative = stepDouble * <a class="code hl_function" href="namespacenc_1_1random_1_1detail.html#af5bfd54c6d5d0ad7e16e6e532b0dfb2e">f</a> * (x * value - result.value);</div>
<div class="line"><a id="l00156" name="l00156"></a><span class="lineno">  156</span> </div>
<div class="line"><a id="l00157" name="l00157"></a><span class="lineno">  157</span>                value_minus_1 = result.value;</div>
<div class="line"><a id="l00158" name="l00158"></a><span class="lineno">  158</span>                result.value  = value;</div>
<div class="line"><a id="l00159" name="l00159"></a><span class="lineno">  159</span>            }</div>
<div class="line"><a id="l00160" name="l00160"></a><span class="lineno">  160</span> </div>
<div class="line"><a id="l00161" name="l00161"></a><span class="lineno">  161</span>            <span class="keywordflow">return</span> result;</div>
<div class="line"><a id="l00162" name="l00162"></a><span class="lineno">  162</span>        }</div>
<div class="line"><a id="l00163" name="l00163"></a><span class="lineno">  163</span> </div>
<div class="line"><a id="l00164" name="l00164"></a><span class="lineno">  164</span>        <span class="comment">//===================================Attributes==============================</span></div>
<div class="line"><a id="l00165" name="l00165"></a><span class="lineno">  165</span>        <span class="keyword">const</span> <span class="keywordtype">double</span> EPSILON{ 1<a class="code hl_variable" href="namespacenc_1_1constants.html#aebabe96d6c2be3df3d71922b399e24c7">e</a>-15 };</div>
<div class="line"><a id="l00166" name="l00166"></a><span class="lineno">  166</span> </div>
<div class="line"><a id="l00167" name="l00167"></a><span class="lineno">  167</span>        <span class="keyword">const</span> <a class="code hl_typedef" href="namespacenc.html#af0f49663fb63332596e2e6327009d581">uint32</a>        numIterations_{};</div>
<div class="line"><a id="l00168" name="l00168"></a><span class="lineno">  168</span>        std::vector&lt;double&gt; weight_{};</div>
<div class="line"><a id="l00169" name="l00169"></a><span class="lineno">  169</span>        std::vector&lt;double&gt; root_{};</div>
<div class="line"><a id="l00170" name="l00170"></a><span class="lineno">  170</span>    };</div>
<div class="line"><a id="l00171" name="l00171"></a><span class="lineno">  171</span> </div>
<div class="line"><a id="l00172" name="l00172"></a><span class="lineno">  172</span>    <span class="comment">//============================================================================</span></div>
<div class="line"><a id="l00173" name="l00173"></a><span class="lineno">  173</span>    <span class="comment">// Method Description:</span></div>
<div class="line"><a id="l00183" name="l00183"></a><span class="lineno">  183</span><span class="comment"></span>    <span class="keyword">inline</span> <span class="keywordtype">double</span></div>
<div class="line"><a id="l00184" name="l00184"></a><span class="lineno"><a class="line" href="namespacenc_1_1integrate.html#af7d17b4e025bf94f903d3c671da3baf7">  184</a></span>        <a class="code hl_function" href="namespacenc_1_1integrate.html#af7d17b4e025bf94f903d3c671da3baf7">gauss_legendre</a>(<span class="keyword">const</span> <span class="keywordtype">double</span> low, <span class="keyword">const</span> <span class="keywordtype">double</span> high, <span class="keyword">const</span> <a class="code hl_typedef" href="namespacenc.html#af0f49663fb63332596e2e6327009d581">uint32</a> n, <span class="keyword">const</span> std::function&lt;<span class="keywordtype">double</span>(<span class="keywordtype">double</span>)&gt;&amp; <a class="code hl_function" href="namespacenc_1_1random_1_1detail.html#af5bfd54c6d5d0ad7e16e6e532b0dfb2e">f</a>)</div>
<div class="line"><a id="l00185" name="l00185"></a><span class="lineno">  185</span>    {</div>
<div class="line"><a id="l00186" name="l00186"></a><span class="lineno">  186</span>        <span class="keyword">const</span> <a class="code hl_class" href="classnc_1_1integrate_1_1_legendre_polynomial.html">LegendrePolynomial</a>   legendrePolynomial(n);</div>
<div class="line"><a id="l00187" name="l00187"></a><span class="lineno">  187</span>        <span class="keyword">const</span> std::vector&lt;double&gt;&amp; weight = legendrePolynomial.<a class="code hl_function" href="classnc_1_1integrate_1_1_legendre_polynomial.html#a5a97c4c53f878cda71129dbd4398b1a9">getWeight</a>();</div>
<div class="line"><a id="l00188" name="l00188"></a><span class="lineno">  188</span>        <span class="keyword">const</span> std::vector&lt;double&gt;&amp; root   = legendrePolynomial.<a class="code hl_function" href="classnc_1_1integrate_1_1_legendre_polynomial.html#a50df5ad7c7312b1bf814fcf8b5bb0d94">getRoot</a>();</div>
<div class="line"><a id="l00189" name="l00189"></a><span class="lineno">  189</span> </div>
<div class="line"><a id="l00190" name="l00190"></a><span class="lineno">  190</span>        <span class="keyword">const</span> <span class="keywordtype">double</span> width = 0.5 * (high - low);</div>
<div class="line"><a id="l00191" name="l00191"></a><span class="lineno">  191</span>        <span class="keyword">const</span> <span class="keywordtype">double</span> <a class="code hl_function" href="namespacenc.html#a2740b304fc854a6595195dafcf3dcf89">mean</a>  = 0.5 * (low + high);</div>
<div class="line"><a id="l00192" name="l00192"></a><span class="lineno">  192</span> </div>
<div class="line"><a id="l00193" name="l00193"></a><span class="lineno">  193</span>        <span class="keywordtype">double</span> gaussLegendre = 0.;</div>
<div class="line"><a id="l00194" name="l00194"></a><span class="lineno">  194</span>        <span class="keywordflow">for</span> (<a class="code hl_typedef" href="namespacenc.html#af0f49663fb63332596e2e6327009d581">uint32</a> step = 1; step &lt;= n; ++step)</div>
<div class="line"><a id="l00195" name="l00195"></a><span class="lineno">  195</span>        {</div>
<div class="line"><a id="l00196" name="l00196"></a><span class="lineno">  196</span>            gaussLegendre += weight[step] * <a class="code hl_function" href="namespacenc_1_1random_1_1detail.html#af5bfd54c6d5d0ad7e16e6e532b0dfb2e">f</a>(width * root[step] + <a class="code hl_function" href="namespacenc.html#a2740b304fc854a6595195dafcf3dcf89">mean</a>);</div>
<div class="line"><a id="l00197" name="l00197"></a><span class="lineno">  197</span>        }</div>
<div class="line"><a id="l00198" name="l00198"></a><span class="lineno">  198</span> </div>
<div class="line"><a id="l00199" name="l00199"></a><span class="lineno">  199</span>        <span class="keywordflow">return</span> gaussLegendre * width;</div>
<div class="line"><a id="l00200" name="l00200"></a><span class="lineno">  200</span>    }</div>
<div class="line"><a id="l00201" name="l00201"></a><span class="lineno">  201</span>} <span class="comment">// namespace nc::integrate</span></div>
<div class="ttc" id="a_core_2_constants_8hpp_html"><div class="ttname"><a href="_core_2_constants_8hpp.html">Constants.hpp</a></div></div>
<div class="ttc" id="a_types_8hpp_html"><div class="ttname"><a href="_types_8hpp.html">Types.hpp</a></div></div>
<div class="ttc" id="aclassnc_1_1integrate_1_1_legendre_polynomial_html"><div class="ttname"><a href="classnc_1_1integrate_1_1_legendre_polynomial.html">nc::integrate::LegendrePolynomial</a></div><div class="ttdef"><b>Definition:</b> gauss_legendre.hpp:49</div></div>
<div class="ttc" id="aclassnc_1_1integrate_1_1_legendre_polynomial_html_a2e1fefae138e66215cd7586a85fc3642"><div class="ttname"><a href="classnc_1_1integrate_1_1_legendre_polynomial.html#a2e1fefae138e66215cd7586a85fc3642">nc::integrate::LegendrePolynomial::LegendrePolynomial</a></div><div class="ttdeci">LegendrePolynomial(const uint32 numIterations) noexcept</div><div class="ttdef"><b>Definition:</b> gauss_legendre.hpp:57</div></div>
<div class="ttc" id="aclassnc_1_1integrate_1_1_legendre_polynomial_html_a50df5ad7c7312b1bf814fcf8b5bb0d94"><div class="ttname"><a href="classnc_1_1integrate_1_1_legendre_polynomial.html#a50df5ad7c7312b1bf814fcf8b5bb0d94">nc::integrate::LegendrePolynomial::getRoot</a></div><div class="ttdeci">const std::vector&lt; double &gt; &amp; getRoot() const noexcept</div><div class="ttdef"><b>Definition:</b> gauss_legendre.hpp:82</div></div>
<div class="ttc" id="aclassnc_1_1integrate_1_1_legendre_polynomial_html_a5a97c4c53f878cda71129dbd4398b1a9"><div class="ttname"><a href="classnc_1_1integrate_1_1_legendre_polynomial.html#a5a97c4c53f878cda71129dbd4398b1a9">nc::integrate::LegendrePolynomial::getWeight</a></div><div class="ttdeci">const std::vector&lt; double &gt; &amp; getWeight() const noexcept</div><div class="ttdef"><b>Definition:</b> gauss_legendre.hpp:71</div></div>
<div class="ttc" id="anamespacenc_1_1constants_html_a2f1219a120c9cc1434486d9de75a8221"><div class="ttname"><a href="namespacenc_1_1constants.html#a2f1219a120c9cc1434486d9de75a8221">nc::constants::pi</a></div><div class="ttdeci">constexpr double pi</div><div class="ttdoc">Pi.</div><div class="ttdef"><b>Definition:</b> Core/Constants.hpp:39</div></div>
<div class="ttc" id="anamespacenc_1_1constants_html_aebabe96d6c2be3df3d71922b399e24c7"><div class="ttname"><a href="namespacenc_1_1constants.html#aebabe96d6c2be3df3d71922b399e24c7">nc::constants::e</a></div><div class="ttdeci">constexpr double e</div><div class="ttdoc">eulers number</div><div class="ttdef"><b>Definition:</b> Core/Constants.hpp:37</div></div>
<div class="ttc" id="anamespacenc_1_1integrate_html"><div class="ttname"><a href="namespacenc_1_1integrate.html">nc::integrate</a></div><div class="ttdef"><b>Definition:</b> gauss_legendre.hpp:43</div></div>
<div class="ttc" id="anamespacenc_1_1integrate_html_af7d17b4e025bf94f903d3c671da3baf7"><div class="ttname"><a href="namespacenc_1_1integrate.html#af7d17b4e025bf94f903d3c671da3baf7">nc::integrate::gauss_legendre</a></div><div class="ttdeci">double gauss_legendre(const double low, const double high, const uint32 n, const std::function&lt; double(double)&gt; &amp;f)</div><div class="ttdef"><b>Definition:</b> gauss_legendre.hpp:184</div></div>
<div class="ttc" id="anamespacenc_1_1random_1_1detail_html_af5bfd54c6d5d0ad7e16e6e532b0dfb2e"><div class="ttname"><a href="namespacenc_1_1random_1_1detail.html#af5bfd54c6d5d0ad7e16e6e532b0dfb2e">nc::random::detail::f</a></div><div class="ttdeci">dtype f(GeneratorType &amp;generator, dtype inDofN, dtype inDofD)</div><div class="ttdef"><b>Definition:</b> f.hpp:56</div></div>
<div class="ttc" id="anamespacenc_1_1utils_html_ae792e10a24b7e5b8291a6c31a28a4512"><div class="ttname"><a href="namespacenc_1_1utils.html#ae792e10a24b7e5b8291a6c31a28a4512">nc::utils::sqr</a></div><div class="ttdeci">constexpr dtype sqr(dtype inValue) noexcept</div><div class="ttdef"><b>Definition:</b> sqr.hpp:42</div></div>
<div class="ttc" id="anamespacenc_html_a2740b304fc854a6595195dafcf3dcf89"><div class="ttname"><a href="namespacenc.html#a2740b304fc854a6595195dafcf3dcf89">nc::mean</a></div><div class="ttdeci">NdArray&lt; double &gt; mean(const NdArray&lt; dtype &gt; &amp;inArray, Axis inAxis=Axis::NONE)</div><div class="ttdef"><b>Definition:</b> mean.hpp:52</div></div>
<div class="ttc" id="anamespacenc_html_a736de91eb8f79bfaf4dc92d7161f1c87"><div class="ttname"><a href="namespacenc.html#a736de91eb8f79bfaf4dc92d7161f1c87">nc::cos</a></div><div class="ttdeci">auto cos(dtype inValue) noexcept</div><div class="ttdef"><b>Definition:</b> cos.hpp:49</div></div>
<div class="ttc" id="anamespacenc_html_af0f49663fb63332596e2e6327009d581"><div class="ttname"><a href="namespacenc.html#af0f49663fb63332596e2e6327009d581">nc::uint32</a></div><div class="ttdeci">std::uint32_t uint32</div><div class="ttdef"><b>Definition:</b> Types.hpp:40</div></div>
<div class="ttc" id="asqr_8hpp_html"><div class="ttname"><a href="sqr_8hpp.html">sqr.hpp</a></div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a class="el" href="dir_34171bd951b13a53aa9f237277a18e40.html">NumCpp</a></li><li class="navelem"><a class="el" href="dir_10b69f38d52e59bd23d9fc1937bea22a.html">Integrate</a></li><li class="navelem"><a class="el" href="gauss__legendre_8hpp.html">gauss_legendre.hpp</a></li>
    <li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.4 </li>
  </ul>
</div>
</body>
</html>
